import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_svg_icons/flutter_svg_icons.dart';

class MSSvgIcon extends StatelessWidget {
  const MSSvgIcon(
    this.name, {
    super.key,
    this.size,
    this.responsiveColor = true,
    this.color,
  });

  final String name;
  final double? size;
  final bool responsiveColor;
  final Color? color;

  @override
  Widget build(BuildContext context) {
    String assetName = 'assets/svg/$name.svg';
    if (responsiveColor) {
      return SvgIcon(
        icon: SvgIconData(assetName),
        size: size,
        responsiveColor: responsiveColor, // 响应式颜色无效
        color: color,
      );
    } else {
      return SvgPicture.asset(assetName, width: size, height: size);
    }
  }
}
